package com.koron.standard.jobStock.overhaul.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koron.standard.jobStock.overhaul.bean.po.OverhaulReady;
import com.koron.standard.jobStock.overhaul.mapper.OverhaulReadyMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 大修标准下工作准备(OverhaulReady)表服务实现类
 *
 * @author jzp
 * @since 2021-09-16
 */
@Service
public class OverhaulReadyService extends ServiceImpl<OverhaulReadyMapper, OverhaulReady> {

    public void removeByOverhaulId(String overhaulId) {
        if (StrUtil.isEmpty(overhaulId)) {
            return;
        }
        List<OverhaulReady> list = listByOverhaulId(overhaulId);
        removeByIds(list.stream().map(OverhaulReady::getId).collect(Collectors.toList()));
    }

    public List<OverhaulReady> listByOverhaulId(String overhaulId) {
        LambdaQueryWrapper<OverhaulReady> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(OverhaulReady::getOverhaulId, overhaulId);
        return list(wrapper);
    }
}
